package org.redis.cluster.transport.netty;

import org.redis.cluster.transport.support.AbstractByteBuffer;

import io.netty.buffer.ByteBuf;

public class NettyByteBuffer extends AbstractByteBuffer {
	
	private ByteBuf byteBuffer;
	
	public NettyByteBuffer(ByteBuf byteBuffer) {
		this.byteBuffer=byteBuffer;
	}
	
	@Override
	public boolean skip(int length) {
		byteBuffer.skipBytes(length);
		return true;
	}

	@Override
	public byte getByte(int position) {
		return byteBuffer.getByte(position);
	}
	
	@Override
	public int readableBytes() {
		return byteBuffer.readableBytes();
	}
	
	@Override
	public boolean isReadable(int length) {
		return byteBuffer.isReadable(length);
	}
	
	@Override
	public boolean isReadable() {
		return byteBuffer.isReadable();
	}

	@Override
	public byte readByte() {
		return byteBuffer.readByte();
	}

	@Override
	public boolean readBytes(byte[] bytes) {
		byteBuffer.readBytes(bytes);
		return true;
	}
	
	@Override
	public int position() {
		return byteBuffer.readerIndex();
	}

	@Override
	public boolean position(int newPosition) {
		byteBuffer.readerIndex(newPosition);
		return true;
	}
}